home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
MORSE_CD
/
MORSE_IN.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-11-11
|
2KB
|
58 lines
/*
This INIT will show it's ICN# and then emit some morse code,
depending on what it finds in the following resource:
'PARM' resource -4048 contains:
1. Boolean (if TRUE then emit morse code).
2. Frequency (Hz).
3. Volume 0...255 (loudest).
4. Speed, dot time in 1/60 seconds.
5. Pascal string with text to send as morse code.
The MorsePlay() function is in code resource 'PLAY' -4048.
Set the project to "code resource" of type 'INIT' with custom header.
*/
#define ICON -4064 /* Resource id of 'ICN#' */
#define PARM -4048 /* Resource id of 'PARM' */
#define PLAY -4048 /* Resource id of 'PLAY' */
typedef void (*PF)(); /* Pointer to function returning void */
typedef struct Parameter { /* Structure of 'PARM' resource */
short enable; /* Morse or not to morse that's the question */
short frequency; /* Hz */
short volume; /* 0..255 (loudest) */
short speed; /* Length of dot in 1/60 seconds */
char text[256]; /* Pascal string, text to morse */
} Parameter, *ParameterPtr, **ParameterHdl;
#define MorsePlay(a,b,c,d) (*mp)(a,b,c,d)
main()
{
register ParameterHdl h;
register ParameterPtr p;
PF mp, *mh;
/* Note: all registers are saved/restored by the system */
asm { LEA main,A4 } /* A4 used for global and static data */
if (h = (ParameterHdl)GetResource('PARM', PARM)) {
HLock(h);
p = *h;
if (p->enable) {
ShowINIT(ICON); /* INIT notification */
if (mh = (PF *)GetResource('PLAY', PLAY)) {
HLock(mh);
mp = *mh;
PtoCstr(p->text);
MorsePlay(p->text, p->frequency, p->volume, p->speed);
ReleaseResource(mh);
}
}
ReleaseResource(h);
}
}